<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript">
var patron = new Array(4,2,2)
function mascara(d,sep,pat,nums){
if(d.valant != d.value){
	val = d.value
	largo = val.length
	val = val.split(sep)
	val2 = ''
	for(r=0;r<val.length;r++){
		val2 += val[r]	
	}
	if(nums){
		for(z=0;z<val2.length;z++){
			if(isNaN(val2.charAt(z))){
				letra = new RegExp(val2.charAt(z),"g")
				val2 = val2.replace(letra,"")
			}
		}
	}
	val = ''
	val3 = new Array()
	for(s=0; s<pat.length; s++){
		val3[s] = val2.substring(0,pat[s])
		val2 = val2.substr(pat[s])
	}
	for(q=0;q<val3.length; q++){
		if(q ==0){
			val = val3[q]
		}
		else{
			if(val3[q] != ""){
				val += sep + val3[q]
				}
		}
	}
	d.value = val
	d.valant = val
	}
}

</script>
<?php
include('../resource/config.php'); 
if (isset($_POST['submitted'])) { 
foreach($_POST AS $key => $value) { $_POST[$key] = mysql_real_escape_string($value); } 
$sql = "INSERT INTO `regcon` ( `NOCT` ,  `SECT` ,  `TEC1` ,  `TEC2` ,  `COEL` ,  `OBSE`  ) VALUES(  '{$_POST['NOCT']}' ,  '{$_POST['SECT']}' ,  '{$_POST['TEC1']}' ,  '{$_POST['TEC2']}' ,  '{$_POST['COEL']}' ,  '{$_POST['OBSE']}'  ) "; 
mysql_query($sql) or die(mysql_error()); 
echo "<script type='text/javascript'>	alert('Agregado con exito'); window.location = 'listar.php';</script>";
} 
?>
<div id='crear'>
<form action='' method='POST'> 
			<p><b>Nombre:</b><br /><input type='text' name='NOCT' maxlength="50" autocomplete='off'/> 
			<p><b>Sexo:</b><br />
			<select name="SECT">
				<option value="">Seleccione</option>
				<option value="M">Masculino</option>
				<option value="F">Femenino</option>
			</select>
			<p><b>Tel fijo:</b><br /><input type='text' name='TEC1' maxlength="10" onkeyup="mascara(this,'-',patron,true)" autocomplete='off'/> 
			<p><b>Tel movil:</b><br /><input type='text' name='TEC2' maxlength="10" onkeyup="mascara(this,'-',patron,true)" autocomplete='off'/> 
			<p><b>Correo:</b><br /><input type='email' name='COEL' maxlength="25" autocomplete='off'/> 
			<p><b>Observación:</b><br /><textarea rows="2" cols="50" name='OBSE' maxlength="50" autocomplete='off'></textarea>
			<p><input type='submit' value='Guardar' class="btn btn-primary"/><input type='hidden' value='1' name='submitted' />
</form> 
<div>